package com.parking.bang.rpc.biz.client;

import java.math.BigDecimal;
import java.util.concurrent.CountDownLatch;

import com.parking.bang.rpc.biz.server.chengfa;
import com.parking.bang.rpc.core.client.MessageSendExecutor;

public class CalcParallelRequestThread implements Runnable {
	private CountDownLatch signal;
	private CountDownLatch finish;
	private MessageSendExecutor executor;
	private int taskNumber = 0;

	public CalcParallelRequestThread(MessageSendExecutor executor, CountDownLatch signal, CountDownLatch finish,
			int taskNumber) {
		this.signal = signal;
		this.finish = finish;
		this.taskNumber = taskNumber;
		this.executor = executor;
	}

	@Override
	public void run() {
		try {
			signal.await();

			chengfa calc = executor.execute(chengfa.class);
			Double add = calc.cheng(new BigDecimal(taskNumber), new BigDecimal(taskNumber));
			System.out.println("calc add result:[" + add + "]");

			finish.countDown();
		} catch (InterruptedException ex) {
			ex.printStackTrace();
		}

	}

}
